﻿using DFGK_WMS.IRepository;
using DFGK_WMS.Model.Models;
using DFGK_WMS.WebAPI.Controllers.Result;
using Microsoft.AspNetCore.Mvc;

namespace DFGK_WMS.WebAPI.Controllers.库存管理
{
    /// <summary>
    /// 库存预警
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class TInventoryAlertController : ControllerBase
    {

        private readonly ITInventoryAlertRepository TInventoryAlert;

        public TInventoryAlertController(ITInventoryAlertRepository TInventoryAlert)
        {
            this.TInventoryAlert = TInventoryAlert;
        }

        /// <summary>
        /// 库存预警查询
        /// </summary>
        /// <param name="WarningType"></param>
        /// <param name="warehouse"></param>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetInventoryWarnPagingList(int? WarningType, int? warehouse, int pageIndex, int pageSize)
        {
            if(pageIndex<=0 || pageSize<=0)
            {
                return Ok(BaseResult.Result("400", "分页条件有误！"));
            }
           var list =  TInventoryAlert.GetInventoryWarnPagingList(out var totalCount, WarningType, warehouse, pageIndex, pageSize);
            if (list != null)
            {
                return Ok(BaseResult.Result(list, "查询成功！", "200", totalCount));

            }
            return Ok(BaseResult.Result(null, "查询失败！", "500", 0));
        }
    }
}
